Repository navigation
#278 - Do not fail the container compilation when the serializer or the validator is disabled - #289
Merged
Merged
Conversation
…he validator is disabled - New internal UnavailableServicesCompilerPass: without serializer, the NormalizerTask, DenormalizerTask, SerializerTask, DeserializerTask services and the normalize / denormalize transformers are replaced by UnavailableTask / UnavailableTransformer (same id, public / shared / tags, transformer code kept), which throw an explicit LogicException when used; same for ValidatorTask without validator (its autowiring failed the compilation). - CheckSerializerCompilerPass is no longer registered, and deprecated. - Documentation (quick start) and tests. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #278: an application that does not enable the Symfony serializer (or validator) can use the bundle; only the tasks / transformers that need it fail, when they are used, with an explicit message.
Before
Checked with a minimal kernel (FrameworkBundle + MonologBundle + this bundle):
framework.serializer.enabled: false: the container does not compile (CheckSerializerCompilerPass, Display a more explicit error message when symfony serializer is not enabled #74):The Symfony serializer component do not seem enabled, consider toggling framework.serializer.enable (…);framework.validation.enabled: false(and serializer disabled, see note):Cannot autowire service "CleverAge\ProcessBundle\Task\Validation\ValidatorTask": argument "$validator" of method "__construct()" references interface "Symfony\Component\Validator\Validator\ValidatorInterface" but no such service exists.Changes
New internal
UnavailableServicesCompilerPass(registered by the bundle instead ofCheckSerializerCompilerPass, runs before autowiring):serializer(norDenormalizerInterfacealias):NormalizerTask,DenormalizerTask,SerializerTask,DeserializerTask→UnavailableTask;NormalizeTransformer,DenormalizeTransformer→UnavailableTransformer;validator(norValidatorInterfacealias):ValidatorTask→UnavailableTask.Same service ids, same
public/ tags (tasks stay non-shared); the transformers keep their code (normalize,denormalize), so thatTransformerRegistrystill knows them and using them gives the explicit message instead of "transformer not found".UnavailableTask/UnavailableTransformer(final readonly,@internal): throw aLogicExceptionwithThe "<service>" service requires the Symfony serializer, which does not seem enabled: consider enabling framework.serializer (see …).(or the validator equivalent,framework.validation) when executed / used. A process using them fails as for any task error (ProcessFailedExceptionwhose previous exception is thisLogicException, with the defaultstopstrategy). Excluded from theTask\/Transformer\resources.CheckSerializerCompilerPass: no longer registered,@deprecated(PHPDoc only, removal in v6.0). No runtime deprecation: it would need the version of the next release, not decided yet; to add if you prefer.Docs: quick start (the serializer / validator are only needed by these tasks and transformers).
CHANGELOG (Latest).
Checks
ConstantOutputTaskprocessNormalizerTaskprocessnormalizetransformerValidatorTaskprocessvendor/then reverted):lint:containerOK,NormalizerTaskkeeps its class,demo.transformerexecuted.UnavailableServicesCompilerPassTest(services kept when available, replaced without serializer / validator, arguments,public/shared/ tags, transformer codes),UnavailableTaskTest,UnavailableTransformerTest. Aftercomposer update: 914 tests OK, PHPStan, PHP-CS-Fixer, Rector OK.Note: serializer enabled with validation disabled does not boot either, because of FrameworkBundle itself (
argument_resolver.request_payloadrequires thevalidator.translation_domainparameter, only defined when the validation is enabled orsymfony/validatoris not installed), not because of this bundle.Requirements
Breaking changes
None: the container compiles in more cases; with the serializer / validator enabled nothing changes.
CheckSerializerCompilerPassis kept (deprecated), only no longer registered by the bundle. Minor.🤖 Generated with Claude Code